#include <iostream>
#include <vector>

using namespace std;
/**
 * @brief
 * 1 <= password.length <= 100
password consists of letters, digits, and special characters: "!@#$%^&*()-+".
 *
 */
class Solution
{
public:
    bool strongPasswordCheckerII(string password)
    {
        int passLen = password.size();
        if (8 > passLen)
        {
            return false;
        }
        int lower = 0, upper = 0, digst = 0, spec = 0;
        for (int i = 0; i < passLen; i++)
        {
            char c = password[i];
            if (i + 1 < passLen && c == password[i + 1])
            {
                return false;
            }

            if (c >= 'a' && c <= 'z')
            {
                lower++;
            }
            else if (c >= 'A' && c <= 'Z')
            {
                upper++;
            }
            else if (c >= '0' && c <= '9')
            {
                digst++;
            }
            else
            {
                spec++;
            }
        }
        // cout << lower << " " << upper << " " << digst << " " << spec << endl;
        return lower > 0 && upper > 0 && digst > 0 && spec > 0;
    }

    bool strongPasswordCheckerII_2(string password)
    {
        int ans = 0,size=password.size();
        for (int i = 0; i < size; i++)
        {
            if (i > 0 && password[i] == password[i - 1])
            {
                return false;
            }
            char ch = password[i];
            if (isdigit(ch))
            {
                ans |= 1;
            }
            else if (islower(ch))
            {
                ans |= 2;
            }
            else if (isupper(ch))
            {
                ans |= 4;
            }
            else
            {
                ans |= 8;
            }
        }
        return size >= 8 && ans == 15;
    }
};
int main()
{
    Solution s;
    cout << s.strongPasswordCheckerII("IloveLe3tcode!") << endl;
    system("pause");
    return 0;
}
